@import "tailwindcss";
@import "@assistant-ui/styles/index.css";
@import "@assistant-ui/styles/markdown.css";

:root {
  /* ============================================
     Breakpoint Variables (Responsive Design)
     ============================================ */
  --breakpoint-xs: 480px;
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
  --breakpoint-2xl: 1536px;
  --breakpoint-3xl: 1920px;
  
  /* ============================================
     Color Variables
     ============================================ */
  --background: 0 0% 100%;
  --foreground: 222.2 84% 4.9%;
  --card: 0 0% 100%;
  --card-foreground: 222.2 84% 4.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 222.2 84% 4.9%;
  --primary: 221.2 83.2% 53.3%;
  --primary-foreground: 210 40% 98%;
  --secondary: 210 40% 96.1%;
  --secondary-foreground: 222.2 47.4% 11.2%;
  --muted: 210 40% 96.1%;
  --muted-foreground: 215.4 16.3% 46.9%;
  --accent: 210 40% 96.1%;
  --accent-foreground: 222.2 47.4% 11.2%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 210 40% 98%;
  --border: 214.3 31.8% 91.4%;
  --input: 214.3 31.8% 91.4%;
  --ring: 221.2 83.2% 53.3%;
  --radius: 0.5rem;
}

.dark {
  /* Cherry Studio inspired dark theme */
  --background: 0 0% 7%;  /* #121212 - Deep dark background */
  --foreground: 0 0% 95%;  /* #F2F2F2 - High contrast text */
  --card: 0 0% 10%;  /* #1A1A1A - Card background */
  --card-foreground: 0 0% 95%;
  --popover: 0 0% 10%;
  --popover-foreground: 0 0% 95%;
  --primary: 217.2 91.2% 59.8%;  /* Blue accent */
  --primary-foreground: 0 0% 100%;
  --secondary: 0 0% 15%;  /* #262626 - Secondary elements */
  --secondary-foreground: 0 0% 95%;
  --muted: 0 0% 15%;
  --muted-foreground: 0 0% 60%;  /* #999999 - Muted text */
  --accent: 0 0% 15%;
  --accent-foreground: 0 0% 95%;
  --destructive: 0 62.8% 30.6%;
  --destructive-foreground: 0 0% 95%;
  --border: 0 0% 20%;  /* #333333 - Subtle borders */
  --input: 0 0% 15%;
  --ring: 217.2 91.2% 59.8%;
}

* {
  border-color: hsl(var(--border));
}

body {
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
}

/* ============================================
   Tab Navigation Styles
   ============================================ */

/* Assistant Tab */
.assistant-tab {
  position: relative;
  padding-left: 1rem;
  padding-right: 1rem;
  padding-top: 0.625rem;
  padding-bottom: 0.625rem;
  transition-property: all;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 200ms;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.assistant-tab:hover {
  background-color: hsl(var(--accent) / 0.5);
}

.assistant-tab[data-active="true"] {
  background-color: hsl(var(--background));
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.assistant-tab[data-active="true"]::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 0.125rem;
  background-color: hsl(var(--primary));
  border-radius: 9999px;
}

.assistant-tab:not([data-active="true"]) {
  color: hsl(var(--muted-foreground));
}

/* Session Tab */
.session-tab {
  position: relative;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
  padding-top: 0.375rem;
  padding-bottom: 0.375rem;
  border-radius: 0.375rem;
  transition-property: all;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 200ms;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 12.5rem;
}

.session-tab:hover {
  background-color: hsl(var(--accent) / 0.3);
}

.session-tab[data-active="true"] {
  background-color: hsl(var(--accent));
  color: hsl(var(--foreground));
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.session-tab[data-active="true"]::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0.125rem;
  background-color: hsl(var(--primary));
  border-radius: 9999px;
}

/* Unread Badge */
.unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.125rem;
  height: 1.125rem;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
  border-radius: 9999px;
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: 0.75rem;
  line-height: 1rem;
  font-weight: 600;
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Tab Close Button */
.tab-close-btn {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  border-radius: 0.125rem;
  opacity: 0;
  transition-property: opacity;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
  display: flex;
  align-items: center;
  justify-content: center;
}

.group:hover .tab-close-btn {
  opacity: 1;
}

.tab-close-btn:hover {
  background-color: hsl(var(--destructive) / 0.2);
  color: hsl(var(--destructive));
}

/* Tab Dragging State */
.tab-dragging {
  opacity: 0.5;
  transform: scale(0.95);
  transition: all 0.2s ease;
}

.tab-drop-target {
  border-left: 2px solid hsl(var(--primary));
}

/* Scrollbar Styling */
.scrollbar-thin {
  scrollbar-width: thin;
  scrollbar-color: hsl(var(--muted)) transparent;
}

.scrollbar-thin::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.scrollbar-thin::-webkit-scrollbar-track {
  background: transparent;
}

.scrollbar-thin::-webkit-scrollbar-thumb {
  background: hsl(var(--muted));
  border-radius: 3px;
}

.scrollbar-thin::-webkit-scrollbar-thumb:hover {
  background: hsl(var(--muted-foreground) / 0.5);
}

/* ============================================
   Thread Width Optimization (P0+ Urgent)
   ============================================ */

/* 响应式内容宽度 - 根据屏幕尺寸动态调整 */
.aui-thread-root {
  /* 默认宽度由 React 动态设置 */
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 确保输入框宽度跟随内容区域 */
.aui-composer-root {
  width: 100%;
  max-width: var(--thread-max-width);
  margin: 0 auto;
  transition: max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 欢迎屏幕也要适配宽度 */
.aui-thread-welcome-root {
  max-width: var(--thread-max-width);
  margin: 0 auto;
}

/* 确保所有内容都在合理宽度内 */
.aui-thread-viewport {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* ============================================
   Enhanced Message Bubble Styles
   ============================================ */

/* Assistant Message - Enhanced with gradient and shadow */
.aui-assistant-message-root {
  display: flex;
  gap: 12px;
  padding: 16px;
  margin: 8px 0;
  border-radius: 12px;
  background: linear-gradient(
    135deg, 
    hsl(var(--card)) 0%, 
    hsl(var(--muted) / 0.3) 100%
  );
  border: 1px solid hsl(var(--border));
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.aui-assistant-message-root:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-color: hsl(var(--primary) / 0.3);
  transform: translateY(-1px);
}

.aui-assistant-message-content {
  max-width: 100%;
  line-height: 1.7;
}

/* User Message - Enhanced with right-aligned gradient */
.aui-user-message-root {
  display: flex;
  gap: 12px;
  padding: 16px;
  margin: 8px 0;
  border-radius: 12px;
  background: linear-gradient(
    135deg,
    hsl(var(--primary) / 0.1) 0%,
    hsl(var(--primary) / 0.05) 100%
  );
  border: 1px solid hsl(var(--primary) / 0.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.aui-user-message-root:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-color: hsl(var(--primary) / 0.4);
  transform: translateY(-1px);
}

/* Enhanced Markdown styles for better readability */
.aui-md {
  font-size: 0.9375rem;
  line-height: 1.7;
}

.aui-md-p {
  margin: 0.75rem 0;
  line-height: 1.7;
}

.aui-md-p:first-child {
  margin-top: 0;
}

.aui-md-p:last-child {
  margin-bottom: 0;
}

/* Ordered and unordered lists */
.aui-md-ol,
.aui-md-ul {
  margin: 0.75rem 0;
  padding-left: 1.75rem;
  line-height: 1.7;
}

.aui-md-ol li,
.aui-md-ul li {
  margin: 0.375rem 0;
  padding-left: 0.25rem;
}

.aui-md-ol {
  list-style-type: decimal;
}

.aui-md-ul {
  list-style-type: disc;
}

/* Nested lists */
.aui-md-ol ol,
.aui-md-ul ul {
  margin: 0.25rem 0;
}

/* Headings */
.aui-md-h1,
.aui-md-h2,
.aui-md-h3,
.aui-md-h4,
.aui-md-h5,
.aui-md-h6 {
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

.aui-md-h1:first-child,
.aui-md-h2:first-child,
.aui-md-h3:first-child {
  margin-top: 0;
}

.aui-md-h1 {
  font-size: 1.5rem;
}

.aui-md-h2 {
  font-size: 1.25rem;
}

.aui-md-h3 {
  font-size: 1.125rem;
}

/* Code blocks */
.aui-md-pre {
  margin: 0.75rem 0;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid hsl(var(--border));
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.aui-code-header-root {
  background: hsl(var(--muted) / 0.5);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid hsl(var(--border));
  padding: 0.5rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s ease;
}

.aui-code-header-root:hover {
  background: hsl(var(--muted) / 0.7);
}

.aui-code-header-language {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: hsl(var(--primary));
  letter-spacing: 0.5px;
}

/* Code copy button enhancement */
.aui-code-header-root button {
  opacity: 0.6;
  transition: opacity 0.2s ease, transform 0.1s ease;
}

.aui-code-header-root:hover button {
  opacity: 1;
}

.aui-code-header-root button:hover {
  transform: scale(1.1);
}

.aui-code-header-root button:active {
  transform: scale(0.95);
}

/* Inline code */
.aui-md-inline-code {
  background: hsl(var(--muted));
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.875em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Blockquotes */
.aui-md-blockquote {
  border-left: 3px solid hsl(var(--primary));
  padding-left: 1rem;
  margin: 0.75rem 0;
  color: hsl(var(--muted-foreground));
  font-style: italic;
}

/* Links */
.aui-md-a {
  color: hsl(var(--primary));
  text-decoration: underline;
  text-underline-offset: 2px;
}

.aui-md-a:hover {
  text-decoration: none;
}

/* Tables */
.aui-md-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
}

.aui-md-th,
.aui-md-td {
  border: 1px solid hsl(var(--border));
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.aui-md-th {
  background: hsl(var(--muted));
  font-weight: 600;
}

/* Horizontal rule */
.aui-md-hr {
  border: none;
  border-top: 1px solid hsl(var(--border));
  margin: 1.5rem 0;
}

/* ============================================
   Welcome Screen Styles
   ============================================ */

.welcome-screen {
  background: radial-gradient(
    ellipse at center,
    hsl(var(--primary) / 0.03) 0%,
    transparent 70%
  );
}

/* Quick Action Card Enhancements */
.quick-action-card {
  position: relative;
  overflow: hidden;
}

.quick-action-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    hsl(var(--primary)) 50%,
    transparent
  );
  opacity: 0;
  transition: opacity 0.3s ease;
}

.quick-action-card:hover::before {
  opacity: 1;
}

/* Scroll to bottom button enhancement */
.aui-thread-scroll-to-bottom {
  position: fixed;
  bottom: 120px;
  right: 32px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10;
  width: 2.5rem;
  height: 2.5rem;
}

.aui-thread-scroll-to-bottom:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
  background: hsl(var(--primary) / 0.9);
}

.aui-thread-scroll-to-bottom:active {
  transform: translateY(0);
}

/* Loading dots animation */
@keyframes loadingDots {
  0%, 20% {
    opacity: 0.3;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
  100% {
    opacity: 0.3;
    transform: scale(1);
  }
}

.loading-dots span {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin: 0 0.125rem;
  border-radius: 50%;
  background-color: currentColor;
  animation: loadingDots 1.4s infinite;
}

.loading-dots span:nth-child(1) {
  animation-delay: 0s;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

/* ============================================
   Animation and Interaction Utilities
   ============================================ */

/* Smooth transitions */
.transition-fast {
  transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.transition-base {
  transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.transition-slow {
  transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hover effects */
.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.hover-grow:hover {
  transform: scale(1.02);
}

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(33, 150, 243, 0.3);
}

/* Active/Click effects */
.active-shrink:active {
  transform: scale(0.95);
}

/* Focus effects */
.focus-ring:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

/* Fade in animation */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in {
  animation: fadeIn 300ms ease-out;
}

/* Slide in from left */
@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.animate-slide-in-left {
  animation: slideInLeft 250ms ease-out;
}

/* Pulse animation for notifications */
@keyframes pulse-soft {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.animate-pulse-soft {
  animation: pulse-soft 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

